package com.nf.controller.manage;

import com.google.gson.Gson;
import com.nf.controller.BaseServlet;
import com.nf.dao.TicketInfoDao;
import com.nf.dao.impl.TicketInfoDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 编写servlet程序，实现计算票房总额
 */
@WebServlet("/api/TicketSumServlet.do")
public class TicketSumServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        TicketInfoDao dao=new TicketInfoDaoImpl();

        int sum= dao.getSum();

        resp.setContentType("application/json;charset=utf-8");
        PrintWriter out = resp.getWriter();

        out.print(new Gson().toJson(successJson(sum)));
        out.flush();
        out.close();
    }
}
